function log(msg) {
		if (window.console) { console.log(msg); }
		var log = document.getElementsByTagName('textarea')[0];
		log.innerHTML = msg+'\r'+log.innerHTML;
	}

	// helper to toggle CSS class
	function toggleClass(elem, name) {
		if (elem.className.indexOf(name) < 0) {
			elem.className += ' '+name;

		} else {
			elem.className = elem.className.split(name).join('');
		}
	}

	//function clearSelection() {
		//var selection =
			//window.getSelection ? window.getSelection() :
			//document.getSelection ? document.getSelection() :
			//document.selection;

		//if (selection && selection.removeAllRanges) {
			// W3C-style
		//	selection.removeAllRanges();

		//} else if (selection && selection.empty) {
			// IE-style
		//	selection.empty();
		//}
	//}

	// generic handler for either event
	function printEvt(e) {
		log(this.id+', '+e.type+': '+e.detail);
		toggleClass(this, 'on'+e.type);
	//	clearSelection();
	}

	var HAS_TOUCH = ('ontouchstart' in window);

	// ----------------------------------------------------
	// Do not enable touch clicks, but monitor both.
	// NOTE: native clicks will fire but touch will not.
	var none = document.getElementById('none');
	this.addEventListener('click', printEvt, false);
	this.addEventListener('dblclick', printEvt, false);

	// ----------------------------------------------------
	// Enable click & dblclick events, and monitor both.
	var both = document.getElementById('both');
	this.addEventListener(HAS_TOUCH ? 'touchend' : 'mouseup', false);
    //doubleTap(), false);
	this.addEventListener('tap', printEvt, false);
	this.addEventListener('dbltap', printEvt, false);

	// ----------------------------------------------------
	// Enable either click or dblclick action, but not both.
	// Do this by only monitoring the click event
	// and forking off e.details (click count) with a delay
	// that suppresses the single click on the second click.
	// http://stackoverflow.com/a/11057483/43217